-
Notifications
You must be signed in to change notification settings - Fork 11
Support Triton repo's triton_kernels custom types via lazy import; add test for single launch and Tensor type #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Summary: - Introduced a new utility in `tritonparse/reproducer/utils.py` for creating kernel launch arguments from a JSON file. - Added a new test case in `tests/test_tritonparse.py` to validate the functionality of the `_topk_forward` kernel with generated arguments. - Cleaned up imports and ensured proper logging during the test execution. - Minor adjustments in `tritonparse/structured_logging.py` to refine type checks for Triton kernel layouts. This update enhances the testing framework and provides a structured way to handle kernel arguments, improving overall code maintainability and test coverage.
Summary: - Introduced a new script `.ci/install-triton-kernels.sh` to automate the installation of Triton kernels from the Triton repository. - The script includes error handling, environment checks, and verification of the installation. - Updated the GitHub Actions workflow in `.github/workflows/test.yml` to call the new installation script as part of the CI process. This addition streamlines the setup process for Triton kernels, ensuring consistency and reducing manual steps during CI runs.
Summary: - Updated `.gitignore` to include the new `repro` directory under `tests/example_output` for better management of test artifacts. - Modified `tests/test_tritonparse.py` to reference the newly added JSON file for kernel argument generation. - Introduced `repro_context_20250816192455.json` in `tests/example_output/repro/` to facilitate testing of the `_topk_forward` kernel with specific context data. These changes enhance the testing framework by ensuring relevant files are tracked and accessible for test cases.
Summary: - Changed the default Triton commit from "main" to "v3.4.0" in the `.ci/install-triton-kernels.sh` script to ensure consistency and stability in kernel installations. This update aligns the installation process with a specific version, improving reliability during CI runs.
… to install triton specifically.
Summary: - Removed direct dependency on Triton and added it as an optional dependency under the new `triton` key. - Introduced a new optional dependency for `pytorch-triton` to specify version requirements. - This change improves flexibility in managing dependencies while ensuring compatibility with different Triton versions.
…ests Summary: - Introduced a check for the presence of the `triton_kernels` module using `importlib.util`. - Updated the `test_triton_kernels_Tensor` method to skip tests if CUDA is not available or if `triton_kernels` is not installed, enhancing test robustness. These changes improve the reliability of the test suite by ensuring that tests are only run in appropriate environments.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
triton_kernels
module (e.g.,Tensor
,Storage
,StridedLayout
).triton_kernels.tensor
by probing availability and importing lazily at use sites..ndjson
log file is produced in the temp logs directorylaunch
event exists in that fileextracted_args["X"].type == "triton_kernels.tensor.Tensor"
Motivation
Tensor
,Storage
,StridedLayout
) are defined in the Triton repo undertriton_kernels
and may not be installed by default. Importing them at module import time causes hard failures for users without the extra.Changes
tritonparse/reproducer/utils.py
TRITON_KERNELS_CUSTOM_TYPES = importlib.util.find_spec("triton_kernels.tensor") is not None
_get_triton_tensor_types()
loadsTensor
,Storage
,StridedLayout
on first use and is decorated withfunctools.lru_cache(maxsize=1)
_create_arg_from_info
branches to:if not TRITON_KERNELS_CUSTOM_TYPES: raise RuntimeError(...)
tests/test_tritonparse.py
test_triton_kernels_Tensor
to:from tritonparse.reproducer import utils as reproducer_utils
tritonparse.structured_logging
with a temp logs directory_topk_forward
once to generate a singlelaunch
event.ndjson
file under the temp logs directory and assert:launch
eventextracted_args["X"].type == "triton_kernels.tensor.Tensor"
TEST_KEEP_OUTPUT=1
)Backward compatibility
RuntimeError
instructing that the dependency is missing. Callers can catch this or ensure the extra is installed.Testing
TestTritonparseCUDA.test_triton_kernels_Tensor
python -m unittest tests.test_tritonparse -v -k test_triton_kernels_Tensor
X
type inextracted_args
.